package com.itheima.service.impl;

import cn.itheima.health.entity.QueryPageBean;
import cn.itheima.health.service.CheckItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.mapper.CheckItemMapper;
import com.itheima.pojo.CheckItem;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
@Transactional
public class CheckItemServiceImpl implements CheckItemService {

    @Autowired
    private CheckItemMapper checkItemMapper;

    @Override
    public void add(CheckItem checkitem) {
        checkItemMapper.add(checkitem);
    }

    @Override
    public Map findPage(QueryPageBean queryPageBean) {
        Map map  = new HashMap();
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        List<CheckItem> list  = checkItemMapper.findPage(queryPageBean.getQueryString());
        PageInfo<CheckItem> pageInfo = new PageInfo<CheckItem>(list);
        map.put("list",pageInfo.getList());
        map.put("total",pageInfo.getTotal());
        return map;
    }

    @Override
    public void deleteCheckItemById(Integer id) {
        checkItemMapper.deleteCheckItemById(id);
    }

    @Override
    public void edit(CheckItem checkitem) {
            checkItemMapper.edit(checkitem);
    }

    @Override
    public List<CheckItem> findAll() {
        return checkItemMapper.findAll();
    }
}











